<?php
class Block_BlkCategoryMenu extends Zend_View_Helper_Abstract
{
	public function blkCategoryMenu ()
	{
		$menu = $this->_createMenu();
		$url = new Zendvn_Filter_Url();
		require_once (BLOCK_PATH . '/BlkCategoryMenu/default.php');
		return;
	}
	
	private function _createMenu($parent = 0)
	{
		$catalogue = new Default_Model_CatalogueMenu($parent);
		$result = $catalogue->getMenu();
		
		$menu = array();
		if ( ! empty($result)) {
			if ($parent != 0) {
				return $result;
			}
			
			$i = 0;
			foreach ($result as $cat) {
				$menu[$i] = $cat;
				if ($catalogue->isParent($cat['id'])) {
					$menu[$i]['sub'] = $this->_createMenu($cat['id']);
				}
				$i++;
			}
			unset($result);
		}
		return $menu;
	}
}